<?php

class ZON_contact_footer_widget extends WP_Widget {
	public function __construct() {
		parent::__construct( 'widget_contact_footer',
							 'Zonthemes - Widget Contact Footer',
							 array( 'description' => __( 'Widget display contact info in footer' ), ) 
		);
	}
	public function widget( $args, $instance ) {
		extract( $args );
		$title = apply_filters( 'title', $instance['title'] );
		$map = apply_filters( 'map', $instance['map'] );
		$address = apply_filters( 'address', $instance['address'] );
		$phone = apply_filters( 'phone', $instance['phone'] );
		$email = apply_filters( 'email', $instance['email'] );
		$facebook = apply_filters( 'facebook', $instance['facebook'] );
		$gplus = apply_filters( 'gplus', $instance['gplus'] );
		$twitter = apply_filters( 'twitter', $instance['twitter'] );
		$pin = apply_filters( 'pin', $instance['pin'] );
		$link = apply_filters( 'link', $instance['link'] );
		?>
		<div class="footer-contact">
			<h3 class="footer-title"><?php echo $title; ?></h3>
			<div class="map-contact-footer">
				<?php echo $map; ?>
			</div>
			<ul class="f-contact">
				<li class="f-add"><?php echo $address; ?></li>
				<li class="f-phone"><?php echo $phone; ?></li>
				<li class="f-email"><a href="mailto:<?php echo $email; ?>" title="<?php echo $email; ?>"><?php echo $email; ?></a></li>
			</ul>
			<ul class="f-social">
				<li class="f-facebook"><a href="<?php echo $facebook; ?>"><img src="<?php bloginfo('template_url'); ?>/images/facebook-icon.png" title="Facebook" alt="facebook"></a></li>
				<li class="f-twitter"><a href="<?php echo $twitter; ?>"><img src="<?php bloginfo('template_url'); ?>/images/twitter-icon.png" alt="Twitter" title="Twitter" /></a></li>
				<li class="f-gplus"><a href="<?php echo $gplus; ?>"><img src="<?php bloginfo('template_url'); ?>/images/gplus-icon.png" title="google plus" alt="goolge plus" /></a></li>
				<li class="f-pin"><a href="<?php echo $pin; ?>"><img src="<?php bloginfo('template_url'); ?>/images/pin-icon.png" title="Pinterest" alt="Pinterest" /></a></li>
				<li class="f-linkedin"><a href="<?php echo $link; ?>"><img src="<?php bloginfo('template_url'); ?>/images/linkedin-icon.png" title="Linkedin" alt="Linkedin" /></a></li>
			</ul>
		</div><!--end .footer.contact-->
		<?php
	}
	public function update( $new_instance, $old_instance ) {
		$instance = $old_instance;
		$instance['title'] = strip_tags( $new_instance['title'] );
		$instance['map'] = strip_tags( $new_instance['map'] );
		$instance['address'] = strip_tags( $new_instance['address'] );
		$instance['phone'] = strip_tags( $new_instance['phone'] );
		$instance['email'] = strip_tags( $new_instance['email'] );
		$instance['facebook'] = strip_tags( $new_instance['facebook'] );
		$instance['gplus'] = strip_tags( $new_instance['gplus'] );
		$instance['twitter'] = strip_tags( $new_instance['twitter'] );
		$instance['pin'] = strip_tags( $new_instance['pin'] );
		$instance['link'] = strip_tags( $new_instance['link'] );
		return $instance;
	}
	public function form( $instance ) {
		$defaults = array( 'title' =>__( 'Contact us' , 'tie') );
		$title = $instance['title'];
		$map = $instance['map'];
		$address = $instance['address'];
		$phone = $instance['phone'];
		$email = $instance['email'];
		$facebook = $instance['facebook'];
		$gplus = $instance['gplus'];
		$twitter = $instance['twitter'];
		$pin = $instance['pin'];
		$link = $instance['link'];
		?>
		<p>
			<label for="<?php echo $this->get_field_id( 'title' ); ?>"><?php _e('Title :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'title' ); ?>" name="<?php echo $this->get_field_name( 'title' ); ?>" value="<?php echo $instance['title']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'layout' ); ?>"><?php _e('Insert code Map :','zonthemes'); ?></label>
			<textarea class="widefat" rows="16" cols="10" id="<?php echo $this->get_field_id('map'); ?>" name="<?php echo $this->get_field_name('map'); ?>"><?php echo $instance['map']; ?></textarea>
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'address' ); ?>"><?php _e('Address :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'address' ); ?>" name="<?php echo $this->get_field_name( 'address' ); ?>" value="<?php echo $instance['address']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'phone' ); ?>"><?php _e('Phone number :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'phone' ); ?>" name="<?php echo $this->get_field_name( 'phone' ); ?>" value="<?php echo $instance['phone']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'email' ); ?>"><?php _e('Email address :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'email' ); ?>" name="<?php echo $this->get_field_name( 'email' ); ?>" value="<?php echo $instance['email']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'facebook' ); ?>"><?php _e('Facebook url :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'facebook' ); ?>" name="<?php echo $this->get_field_name( 'facebook' ); ?>" value="<?php echo $instance['facebook']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'gplus' ); ?>"><?php _e('Google plus url :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'gplus' ); ?>" name="<?php echo $this->get_field_name( 'gplus' ); ?>" value="<?php echo $instance['gplus']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'twitter' ); ?>"><?php _e('Twitter url :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'twitter' ); ?>" name="<?php echo $this->get_field_name( 'twitter' ); ?>" value="<?php echo $instance['twitter']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'pin' ); ?>"><?php _e('Pinterest url :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'pin' ); ?>" name="<?php echo $this->get_field_name( 'pin' ); ?>" value="<?php echo $instance['pin']; ?>" class="widefat" type="text" />
		</p>

		<p>
			<label for="<?php echo $this->get_field_id( 'link' ); ?>"><?php _e('Linkedin url :','zonthemes'); ?></label>
			<input id="<?php echo $this->get_field_id( 'link' ); ?>" name="<?php echo $this->get_field_name( 'link' ); ?>" value="<?php echo $instance['link']; ?>" class="widefat" type="text" />
		</p>

		<?php
	}
}
add_action( 'widgets_init', create_function( '', 'register_widget( "ZON_contact_footer_widget" );' ) );
